public with Sharing class SearchClaimsVF
{
    public String opportunityName {get; set;}
    public String claimStatus {get; set;}
    public String claimName {get; set;}
    public Date filingDate {get; set;}
    public Claim__c c {get; set;}
    
    public CLaim__c[] claimsList {get; set;}
    
    public SearchClaimsVF()
    {
        c = new Claim__c();
        claimsLIst = null;
    }
    
    public List<SelectOption> getClaimStatusList()
    {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('select', 'Select'));
        options.add(new SelectOption('Pending Approval', 'Pending Approval'));
        options.add(new SelectOption('Approved', 'Approved'));
        options.add(new SelectOption('Rejected', 'Rejected'));
        return options;
    }
    
    public PageReference searchClaims()
    {
        if(claimStatus == 'select')
            claimStatus = '%';     
            
        if(claimName == '')
            claimName = '%';
        else
            claimName = '%'+claimName+'%';
        
        if(c.Opportunity__c == null)
            claimsList = [select Id, Name, Claim__c.Opportunity__c, Claim__c.Opportunity__r.Name, Claim_Status__c, Commission_Rate__c, Commission_Amount__c, Credit__c from Claim__c where claim_status__c like :claimStatus and Name like :claimName];// and Opportunity__c like :c.Opportunity__c];
        else
            claimsList = [select Id, Name, Claim__c.Opportunity__c, Claim__c.Opportunity__r.Name, Claim_Status__c, Commission_Rate__c, Commission_Amount__c, Credit__c from Claim__c where claim_status__c like :claimStatus and Name like :claimName and Opportunity__c = :c.Opportunity__c];
        
        if(claimsList.size() == 0)
            claimsList = null;
        return null;
    }
}